#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct FenwickTree {
	int **data_a;
	int **data_b;
	int n;
};


void
swap_ints(int *a, int *b)
{
	int t = *a;
	*a    = *b;
	*b    = t;
}

int
rsq_sq_(int **b, int x, const int y)
{
	register int ret = 0, i = 0;

	if (x < 0 || y < 0)
		return 0;

	while (x >= 0) {
		i = y;
		while (i >= 0) {
			ret += b[x][i];
			i = (i & (i + 1)) - 1;
		}
		x = (x & (x + 1)) - 1;
	}
	return ret;
}

int
rsq_sq(int **b, int x1, int y1, int x2, int y2)
{
	register int ret = 0;
	ret  = rsq_sq_(b, x2, y2);
#ifdef DEBUG
	printf(" 1: ret=%d\n", ret);
#endif
	ret -= rsq_sq_(b, x2, y1-1);
#ifdef DEBUG
	printf(" 2: ret=%d\n", ret);
#endif
	ret -= rsq_sq_(b, x1-1, y2);
#ifdef DEBUG
	printf(" 3: ret=%d\n", ret);
#endif
	ret += rsq_sq_(b, x1-1, y1-1);
#ifdef DEBUG
	printf(" 4: ret=%d\n", ret);
#endif
	return ret;
}

void
add_update_sq(struct FenwickTree *ft, int x, int y)
	/* inc by 1 */
{
	register int i = 0;

	ft->data_a[x][y]++;
	while (x < ft->n) {
		i = y;
		while (i < ft->n) {
			ft->data_b[x][i]++;
			i |= i + 1;
		}
		x |= x + 1;
	}
}

void
my_alloc(struct FenwickTree *ft)
{
	register int i=0;
	ft->data_a = (int**) calloc((size_t) ft->n, sizeof(int*));
	ft->data_b = (int**) calloc((size_t) ft->n, sizeof(int*));
	for (i = 0 ; i < ft->n ; ++i) {
		ft->data_a[i] = (int*) calloc((size_t) ft->n, sizeof(int));
		ft->data_b[i] = (int*) calloc((size_t) ft->n, sizeof(int));
	}
}

void
my_free(struct FenwickTree *ft)
{
	register int i=0;
	for (i = 0 ; i < ft->n ; ++i) {
		free(ft->data_a[i]);
		free(ft->data_b[i]);
	}
	free(ft->data_a);
	free(ft->data_b);
}

#ifdef DEBUG
void
print_everything(struct FenwickTree *ft)
{
	register int i, j;

	printf("\tA:\n");
	for (i = 0 ; i < ft->n ; ++i) {
		printf("%4d", ft->data_a[i][0]);
		for (j = 1 ; j < ft->n ; ++j) {
			printf(" , %4d", ft->data_a[i][j]);
		}
		putchar('\n');
	}

	printf("\tB:\n");
	for (i = 0 ; i < ft->n ; ++i) {
		printf("%4d", ft->data_b[i][0]);
		for (j = 1 ; j < ft->n ; ++j)
			printf(" , %4d", ft->data_b[i][j]);
		putchar('\n');
	}
	putchar('\n');
}
#endif

int
main(void)
{
	struct FenwickTree ft;
	char str[256];
	int x1, y1, x2, y2;

	scanf("%d%*d\n", &ft.n);
	my_alloc(&ft);
	while (fgets(str, 256, stdin)) {
		if (!strncmp(str, "ADD", 3)) {
			(void) sscanf(&str[3], "%d%d", &x1, &y1);
			add_update_sq(&ft, x1-1, y1-1);
#ifdef DEBUG
			print_everything(&ft);
#endif
		} else if (!strncmp(str, "GET", 3)) {
			(void) sscanf(&str[3], "%d%d%d%d", &x1, &y1, &x2, &y2);
			if (x1 > x2)
				swap_ints(&x1, &x2);
			if (y1 > y2)
				swap_ints(&y1, &y2);
			(void) printf("%d\n", rsq_sq(ft.data_b, x1-1, y1-1, x2-1, y2-1));
		} else {
			(void) fprintf(stderr, "unknown cmd: %s", str);
		}
	}
	my_free(&ft);
	return 0;
}
